<html>
<head><meta charset="utf-8"><title>Custom subcommand that can be used with or without cargo? · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html">Custom subcommand that can be used with or without cargo?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212504246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212504246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212504246">(Oct 07 2020 at 00:56)</a>:</h4>
<p>I want <code>cargo mycommand</code> and <code>cargo-mycommand</code> to both work. But since cargo passes <code>mycommand</code> as the first argument for <code>cargo mycommand</code>, I can't take positional arguments - there's no way to tell the different between <code>cargo-mycommand mycommand</code> and <code>cargo mycommand</code>. Is there a recommended way to do this?</p>



<a name="212505634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212505634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212505634">(Oct 07 2020 at 01:21)</a>:</h4>
<p>Can you skip the first argument if it is <code>mycommand</code>?  Most third-party subcommands that I've seen don't bother, but I think it should doable.</p>



<a name="212505692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212505692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212505692">(Oct 07 2020 at 01:22)</a>:</h4>
<p>well but then I can't fix files named <code>mycommand</code></p>



<a name="212505720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212505720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212505720">(Oct 07 2020 at 01:22)</a>:</h4>
<p>that is <em>a</em> solution, but I would prefer it not to be <em>the</em> solution</p>



<a name="212580937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212580937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212580937">(Oct 07 2020 at 16:03)</a>:</h4>
<p>unless I'm missing something, these cases are trivial to differentiate based on (to use C terminology) <code>ARGV[0]</code></p>



<a name="212581020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581020">(Oct 07 2020 at 16:04)</a>:</h4>
<p><span class="user-mention" data-user-id="132721">@Tony Arcieri</span> this is argv[1], not argv[0]</p>



<a name="212581042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581042">(Oct 07 2020 at 16:04)</a>:</h4>
<p>argv[0] is always the name of the program regardless of whether it's run with cargo or not</p>



<a name="212581054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581054">(Oct 07 2020 at 16:04)</a>:</h4>
<p>yes, exactly</p>



<a name="212581089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581089">(Oct 07 2020 at 16:04)</a>:</h4>
<p>right, I'm saying argv[0] is not different between the two</p>



<a name="212581095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581095">(Oct 07 2020 at 16:04)</a>:</h4>
<p>you can differentiate them by whether or not the first argument ends with <code>cargo</code></p>



<a name="212581108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581108">(Oct 07 2020 at 16:04)</a>:</h4>
<p>it's not?</p>



<a name="212581133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581133">(Oct 07 2020 at 16:04)</a>:</h4>
<p>the name of this program is <code>cargo-intraconv</code></p>



<a name="212581151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581151">(Oct 07 2020 at 16:04)</a>:</h4>
<p>When <code>cargo foo</code> runs <code>cargo-foo</code>, the <code>argv[0]</code> will be <code>cargo-foo</code>.</p>



<a name="212581179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581179">(Oct 07 2020 at 16:05)</a>:</h4>
<p>oh</p>



<a name="212581199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581199">(Oct 07 2020 at 16:05)</a>:</h4>
<p>well then!</p>



<a name="212581326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581326">(Oct 07 2020 at 16:05)</a>:</h4>
<p>Ideally I would like cargo not to pass <code>intraconv</code> as the first argument but that will probably break all the existing subcommands</p>



<a name="212581327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212581327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212581327">(Oct 07 2020 at 16:05)</a>:</h4>
<p>So if you run <code>cargo foo a b c</code>, cargo runs <code>cargo-foo foo a b c</code>.</p>



<a name="212582699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212582699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212582699">(Oct 07 2020 at 16:16)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F/near/212581326">said</a>:</p>
<blockquote>
<p>Ideally I would like cargo not to pass <code>intraconv</code> as the first argument but that will probably break all the existing subcommands</p>
</blockquote>
<p>Yeah, unfortunately I don't think that's an option.</p>



<a name="212582775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212582775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212582775">(Oct 07 2020 at 16:16)</a>:</h4>
<p>On the other hand, I think Cargo <em>could</em> set a private environment variable to let you know that you're being run as a subcommand, to disambiguate.</p>



<a name="212582833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212582833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212582833">(Oct 07 2020 at 16:17)</a>:</h4>
<p>(Or, ideally, we could provide a <code>cargo_subcommand</code> crate that you could import to manage that for you.)</p>



<a name="212582844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212582844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212582844">(Oct 07 2020 at 16:17)</a>:</h4>
<p>sounds good to me :)</p>



<a name="212582897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212582897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212582897">(Oct 07 2020 at 16:17)</a>:</h4>
<p>does cargo have an arg-parsing library it re-exports already?</p>



<a name="212583037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212583037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212583037">(Oct 07 2020 at 16:18)</a>:</h4>
<p>Cargo could, in the child process, set a <code>_CARGO_SUBCOMMAND=intraconv</code> variable. You (or a library) could look for that and remove <code>argv[1]</code> iff it matches your program name.</p>



<a name="212583080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212583080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212583080">(Oct 07 2020 at 16:18)</a>:</h4>
<p>Cargo exports less than it should in that area, I think.</p>



<a name="212583511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212583511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212583511">(Oct 07 2020 at 16:21)</a>:</h4>
<p>cargo does also appear to always call it with an absolute path to the binary?</p>



<a name="212583601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212583601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212583601">(Oct 07 2020 at 16:22)</a>:</h4>
<p>so the ambiguous case is one where the path is both absolute and the first argument is the same as the name of the subcommand</p>



<a name="212613540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212613540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matthiaskrgr <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212613540">(Oct 07 2020 at 20:14)</a>:</h4>
<p>if I understand correctly I solved this when using <code>clap</code>, by defining a "mycommand" subcommand and implementing all the flags for the root command as well for that subcommand (so <code>cargo-mycommand</code> as well as <code>cargo mycommand</code> needed to implement the default command line interface)<br>
<a href="https://github.com/matthiaskrgr/cargo-cache/blob/master/src/cli.rs#L209">https://github.com/matthiaskrgr/cargo-cache/blob/master/src/cli.rs#L209</a></p>



<a name="212616518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212616518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212616518">(Oct 07 2020 at 20:42)</a>:</h4>
<p><span class="user-mention" data-user-id="217864">@matthiaskrgr</span> yeah I did something similar in <code>cargo-lock</code>, the problem is there's an ambiguous case where you accept "free" arguments where one can be the same name as the cargo subcommand</p>



<a name="212632511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212632511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212632511">(Oct 07 2020 at 23:33)</a>:</h4>
<p>FWIW this is <em>mostly</em> beside the point because I'd expect all my arguments to end in <code>.rs</code>, since their filenames</p>



<a name="212632558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212632558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212632558">(Oct 07 2020 at 23:34)</a>:</h4>
<p>but there's nothing <em>enforcing</em> rust files have to end with .rs</p>



<a name="212850162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212850162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pksunkara <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212850162">(Oct 09 2020 at 16:51)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> If you are looking for arg parsing library, you can use clap. And you can do what <span class="user-mention" data-user-id="217864">@matthiaskrgr</span> did but make sure not to have free args</p>



<a name="212858962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212858962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212858962">(Oct 09 2020 at 18:15)</a>:</h4>
<p><span class="user-mention" data-user-id="254853">@pksunkara</span> an arg-parsing library won't help; there is fundamentally ambiguity here. I <em>want</em> to have free args for my command.</p>



<a name="212859165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Custom%20subcommand%20that%20can%20be%20used%20with%20or%20without%20cargo%3F/near/212859165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pksunkara <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Custom.20subcommand.20that.20can.20be.20used.20with.20or.20without.20cargo.3F.html#212859165">(Oct 09 2020 at 18:17)</a>:</h4>
<p>Yeah, unfortunately it's not possible. I have tried quite a bit few months ago. The only way to do it is to change how cargo calls them, but that would break everything</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>